<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>vue-component</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <style>
        body {
            padding-top: 50px;
        }

        .starter-template {
            padding: 40px 15px;
            text-align: center;
        }

        /*
         * Footer
         */

        .blog-footer {
            padding: 40px 0;
            color: #999;
            text-align: center;
            background-color: #f9f9f9;
            border-top: 1px solid #e5e5e5;
        }

        .blog-footer p:last-child {
            margin-bottom: 0;
        }
    </style>
</head>
<body>

<div id="app">
    <div class="container">
        <navbar></navbar>


        <mainer :ctitle="title"></mainer>
        <mainer :ctitle="title"></mainer>
        <mainer :ctitle="title"></mainer>
        <mainer :ctitle="title"></mainer>

    </div>

    <foot></foot>
</div>


<!--template-->
<template id="navbars">
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                        aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Project name</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">

                    <li v-for="(item, index) in nav" :class="{active:currentIndex === index}"><a href="#">{{item}}</a>
                    </li>
                    <li><a href="#about">About</a></li>
                    <li><a href="#contact">Contact</a></li>

                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </nav>
</template>


<template id="mainContent">
    <div class="starter-template">
        <h1>{{ctitle}}</h1>
        <p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a
            mostly barebones HTML document.</p>
    </div>
</template>

<script src="./vue.js"></script>

<script>

    //2、注册组件
    Vue.component('navbar', {
        template: '#navbars',
        data() {
            return {
                nav: ['首页', 'PHP', 'VUE', 'Nodejs', 'Golang'],
                currentIndex: 0
            }
        }
    });

    const app = new Vue({
        el: '#app',
        data: {
            title: 'Bootstrap starter template'
        },
        methods: {},
        computed: {},

        components: {
            'mainer': {
                props: ['ctitle'],
                data() {
                    return {}
                },
                template: '#mainContent'
            },


            'foot': {
                template: `
                    <footer class="blog-footer">
                      <p>Blog template built for <a href="http://getbootstrap.com">Bootstrap</a> by <a href="https://twitter.com/mdo">@mdo</a>.</p>
                      <p>
                        <a href="#">Back to top</a>
                      </p>
                    </footer>
                `
            }


        }

    });


</script>


</body>
</html>